package eight.tset_8_8;

import java.util.Scanner;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            if(x % 2 == 0) {
                System.out.println(x);
                continue;
            }
            boolean b = false;
            int[] arr = getArr(x);
            for (int j = 0; j < arr.length; j++) {
                if(arr[j] % 2 == 0) {
                    b = true;
                    int tmp = arr[0];
                    arr[0] = arr[j];
                    arr[j] = tmp;
                    break;
                }
            }
            if(b) {
                for (int j = arr.length - 1; j >= 0; j--) {
                    System.out.print(arr[j]);
                }
            } else {
                System.out.println(-1);
            }
        }
    }
    private static int[] getArr(int x) {
        int tmp = x;
        int l = 0;
        while (tmp > 0) {
            tmp /= 10;
            l++;
        }
        int[] arr = new int[l];
        int i = 0;
        while (x > 0) {
            arr[i] = x % 10;
            x /= 10;
            i++;
        }
        return arr;
    }
}
